Previous Book Contents Book Index Next

Inside Macintosh: QuickDraw GX Objects /
Chapter 4 - Colors and Color-Related Objects / About Color in QuickDraw GX


Color Conversion and Color Matching

Color support in QuickDraw GX is designed for device independence. You can work in whatever color space is most convenient for you, you can convert colors from one color space to another, and you can input and output colors with a variety of physical devices with minimum error and loss of information.

You may want to explicitly convert from one color space to another for a variety of reasons, such as

In addition, QuickDraw GX automatically converts colors from one space to another whenever necessary, such as when it displays a color that is defined in terms of one space on a device whose colors are defined in terms of another space.

When converting among color spaces within a base family (such as HSV to RGB) and for display on the same device, the conversion is exact and there is no loss or error. However, when converting across base families (such as RGB to CMYK, or HLS to XYZ), and when converting within the same family but across different display devices, device dependence is introduced and must be accounted for.

Different imaging devices (scanners, monitors, printers) work in different color spaces and each can have a different gamut, or range of colors that it can produce. Monitors from different manufacturers all display colors in RGB, but may have different RGB gamuts. Printers that work in CMYK space vary drastically in their gamuts, especially if they use different printing technologies. Even a single printer's gamut can vary significantly with the ink or type of paper it uses. It's easy to see that conversion from RGB colors on an individual monitor to CMYK colors on an individual printer using a particular paper type can lead to unpredictable results.

When an image is output to a particular device, the device displays only those colors that are within its gamut. Likewise, when an image is created by scanning, only those colors within the scanner's gamut are saved. Devices with different gamuts cannot reproduce each others' colors exactly, but careful shifting of the colors used on one device can improve the visual match when the image is displayed on another.

Figure 4-15 shows examples of two devices' color gamuts, projected onto Yxy space. Both devices produce less than the total possible range of colors, and device B is restricted to a significantly smaller range than device A. The problem illustrated by Figure 4-15 is to be able to display the same image on both devices with a minimum of visual mismatch. The solution to the problem is the use of color profiles and color-matching methods.

Figure 4-15 Color gamuts for two devices (in Yxy space)

Color Profiles

Converting colors accurately across different input or display devices is called color matching. To perform color matching requires the use of a color profile for each device involved. A color profile describes the characteristics of a color space for a particular physical device in a particular state. A monitor, for example, might have a single color profile, whereas a printer might have a different profile for each paper type or ink type it uses. A color-matching method uses a color profile to convert a color in a given color space on a given device to or from another color space or device, perhaps a device-independent color space.

Different color profiles can have different kinds of information in them. However, any color profile has at least two parts: a set of profile chromaticities and a set of profile response curves. The profile chromaticities are color values that define the extremes of saturation that the device can produce for its primary and secondary colors (red, green, blue, cyan, magenta, yellow). Each color value is typically described in terms of a device-independent space such as XYZ. You can think of the profile's chromaticities as defining points at the extremes of that device's gamut, as shown in Figure 4-16. (The points in Figure 4-16 correspond to the limits of the gamut for device A in Figure 4-15.)

Figure 4-16 Profile chromaticities for a device (in Yxy space)

The profile response curves are graphs that describe how the profile chromaticities ramp from no intensity to full intensity (there are additional response curves for undercolor removal and black generation in CMYK space). The response curves are analogous to gamma curves for monitors or dot-pitch curves for printing. Figure 4-17 shows an example of a single response curve.

Figure 4-17 A profile response curve for a device

Color profiles contain additional information, such as a specification of how to apply the chromaticities and response curves for matching (see the next section, "Color-Matching Methods"), and a name string. They may also have custom information used by particular color-matching methods. QuickDraw GX uses color profiles following the format defined by the ColorSync Utilities. See the ColorSync Utilities chapter of Inside Macintosh: Advanced Color Imaging for more information.

Color profiles are optional; a given color structure may or may not contain a valid reference to a color profile. If a color profile reference is attached, QuickDraw GX uses it when converting or matching colors; if there is no attached profile, QuickDraw GX uses the default QuickDraw GX color profile; see "The Default Color Profile" on page 4-37.

Color-Matching Methods

When colors consistent with one device's gamut are displayed on a device with a different gamut, as in Figure 4-15 on page 4-28, a color-matching method attempts to minimize the perceived differences in the displayed colors between the two devices. The default Apple color-matching method, as used with the ColorSync Utilities, uses these three approaches:

Figure 4-18 Maintaining lightness and maintaining saturation in color matching

QuickDraw GX uses the Macintosh ColorSync Utilities for color matching. ColorSync color-matching methods are Component Manager components and support all three kinds of color-matching, and may support other kinds as well. QuickDraw GX color profile objects contain ColorSync color profile structures, and each structure specifies the kind of matching that should be performed with it.

For more information on ColorSync and color-matching methods, see the ColorSync Utilities chapter of Inside Macintosh: Advanced Color Imaging. For more information on Component Manager components, see the Component Manager chapter of Inside Macintosh: More Macintosh Toolbox.

When Color Matching Occurs

Color profiles are associated with devices. For example, when a QuickDraw GX-aware scanning application creates a scanned image, it produces a bitmap and attaches a color profile object (containing profile information obtained from the scanner driver) to the bitmap. The color profile that is associated with a shape and describes the characteristics of the device on which the shape was created is called the source profile. If the colors in the bitmap are subsequently converted to another color space by the scanning application or by another QuickDraw GX application, QuickDraw GX uses that source profile to match the colors when converting. Bitmaps are described in the bitmap shapes chapter of Inside Macintosh: QuickDraw GX Graphics.

To display the bitmap requires using another color profile, which is attached to the view device object associated with the output device. (View device objects are described in the chapter "View-Related Objects" in this book.) That color profile is called the destination profile. If the bitmap is displayed on a monitor, QuickDraw GX uses the monitor's color profile, along with the bitmap's source profile, to match the bitmap's colors to the monitor's gamut. If the bitmap is printed, QuickDraw GX uses the printer's profile to match the bitmap's colors to the printer, including generating black and removing undercolors where appropriate.

QuickDraw GX color matching occurs automatically, whenever drawing takes place or whenever colors are converted from a color space in one base family to a color space in a different base family. Most applications need not know what profiles, if any, are attached to the colors they manipulate and draw. However, applications can explicitly use color profiles for purposes such as print previewing, or they can allow the user to create custom, modified profiles for special purposes on particular devices. In addition, specialized applications can calibrate display devices and produce color profiles whose information is stored in the devices' drivers for use by QuickDraw GX. Such applications make use of the ColorSync Utilities to create their profiles.

Color matching is off by default
Color matching can slow drawing speed. For that reason, when you create a view port, the view port attribute gxEnableMatchPort is cleared by default. If you want matching to occur when you draw to the screen, you must first set gxEnableMatchPort. (Matching occurs when appropriate during printing, regardless of the state of the gxEnableMatchPort attribute.) View port attributes are discussed in the chapter "View-Related Devices" in this book.
For more information on color profiles, see the section "About Color Profile Objects" beginning on page 4-35.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
7 JUL 1996